package donggui;

public class item121 {
    public static int maxProfit(int[] prices) {
        int start =0;
        int end  =prices.length-1;
        int max =0;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i <=end ; i++) {
            if(prices[i]<min)
            {
                min = prices[i];
            }else if(prices[i]-min>max)
            {
                max = prices[i]-min;
            }
        }
    return max;
    }

    public static void main(String[] args) {
        int []num = {7,1,5,3,6,4};
        maxProfit(num);
    }
}
